// **** new code
package com.app.GoCuro;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ManualInputActivity extends Activity {

	String contents = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.manualinput);

		Button btn_Confirm = (Button) findViewById(R.id.button_confirm);
		final EditText et_itemName = (EditText) findViewById(R.id.editText_itemname);
		final EditText et_itemQuan = (EditText) findViewById(R.id.editText_itemquantity);

		btn_Confirm.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				// validate input (should not empty)
				// save input and go to DatabaseActionsActivity
				String itemName_str = et_itemName.getText().toString();
				String itemQuan_str = et_itemQuan.getText().toString();

				contents = "item name: " + itemName_str + '\n'
						+ "barcode number: " + '\n' + "item quantity: "
						+ itemQuan_str;

				Calendar c = Calendar.getInstance();
				SimpleDateFormat f = new SimpleDateFormat(
						"yyyy-MM-dd HH:mm:ss a");
				String formattedDateTime = f.format(c.getTime());

				String confirmText = formattedDateTime + '\n' + contents + '\n'
						+ "data sending back to server......";
				Toast.makeText(getApplicationContext(), confirmText,
						Toast.LENGTH_LONG).show();

				Intent DatabaseActionsActivityIntent = new Intent(
						ManualInputActivity.this, DatabaseActionsActivity.class);
				Bundle manualInputData = new Bundle();
				manualInputData.putString("datatime", formattedDateTime);
				manualInputData.putString("manualInputContents", contents);

				DatabaseActionsActivityIntent.putExtras(manualInputData);
				ManualInputActivity.this
						.startActivity(DatabaseActionsActivityIntent);
			}
		});
	}
}
